package com.example.service.impl;

import ch.qos.logback.classic.Logger;
import com.example.entity.activity.Activity1;
import com.example.mapp.ActivityMapp;
import com.example.service.ActivityService;
import com.example.util.ResultUtil;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created by simon on 2018/12/18.
 */
@Service
public class ActivityServiceImpl implements ActivityService {

    private final static Logger logger = (Logger) LoggerFactory.getLogger(ActivityServiceImpl.class);

    @Autowired
    ActivityMapp activityMapp;

    @Override
    public Map<String, Object> addActivity1(Activity1 activity1) {
        try{
            List<Activity1> activity1List =activityMapp.queryActivity1(activity1);
            if(activity1List==null || activity1List.size()<=0){
                activityMapp.addActivity1(activity1);
            }

        }catch (Exception e){
            logger.error("活动1 记录失败",e);
            return  ResultUtil.returnError("失败",null);
        }
        return  ResultUtil.returnSuccess("成功",null);
    }
}
